//
//  textDetailViewController.swift
//  fsapp
//
//  Created by zguang on 17/8/22.
//  Copyright © 2017年 huangshengjie. All rights reserved.
//

import UIKit

class textDetailViewController: UIViewController {

    var id:Int?
    var contentText:String?
    var ttitle: String?
    init(title:String,content:String,index:Int) {
        super.init(nibName: nil, bundle: nil)
        self.id = index
        self.contentText = content
        self.ttitle = title
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
              self.view.backgroundColor = UIColor.white
//        let label = UITextView(frame: CGRect(x:0,y:0,width:SCREEN_WIDTH,height:SCREEN_HEIGHT))
//        //var htmlText = "空は<font color=\"blue\">青い</font>。<br>An apple is <font color=\"red\">red</font>."
//        do{
//            let attrStr = try NSAttributedString(data: (contentText?.data(using: String.Encoding.unicode, allowLossyConversion: true))!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
//            
//            label.attributedText = attrStr
//            //label.numberOfLines = 0
//            
//            let scrollView = UIScrollView()
//            scrollView.frame = self.view.bounds
//            //let imageView = UIImageView(image:UIImage(named:"bigpic"))
//            scrollView.contentSize = label.bounds.size
//            scrollView.addSubview(label)
//           // self.view.addSubview(scrollView)
//           // label.sizeToFit()
//        }catch let error as NSError {
//            print(error.localizedDescription)
//        }
        let dict:NSDictionary = [NSForegroundColorAttributeName: UIColor.white,NSFontAttributeName : UIFont.boldSystemFont(ofSize: 18)]
        //标题颜色
        self.navigationController?.navigationBar.titleTextAttributes = dict as? [String : AnyObject]
        self.navigationItem.title = ttitle
        var webView = UIWebView(frame: self.view.frame)
        webView.loadHTMLString(contentText!, baseURL: nil)
        webView.scalesPageToFit = true
        self.view.addSubview(webView)
        
        
       // self.view.addSubview(label)
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
